using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

using DataAccess;
using DataTransferObject;

namespace Business
{
    public enum TapChiBUSResult
    {
        OK,
        MATAPCHIERROR,
        TENTAPCHIERROR,
        TENKYERROR,
        THOIGIANERROR,
        NGAYNHAPERROR,
        NGONNGUERROR,
        TRANGTHAIERROR,
        DAOERROR
    }

    public class clsTapChiBUS
    {
        //Fields.
        private clsTapChiDAO TapChiDAO;

        //Constructors.
        public clsTapChiBUS()
        {
            this.TapChiDAO = new clsTapChiDAO();
        }

        #region Methods

        //Phương thức tìm tạp chí.
        public clsTapChiDTO TimTapChi(clsTapChiDTO obj)
        {
            return TapChiDAO.TimTapChi(obj);
        }

        public DataTable DanhSachTapChi()
        {
            return this.TapChiDAO.SelectAll();
        }

        public TapChiBUSResult ThemTapChi(clsTapChiDTO obj)
        {
            if (!this.TapChiDAO.Insert(obj))
                return TapChiBUSResult.DAOERROR;
            return TapChiBUSResult.OK;
        }

        public TapChiBUSResult SuaTapChi(clsTapChiDTO obj)
        {
            if (!this.TapChiDAO.Update(obj))
                return TapChiBUSResult.DAOERROR;
            return TapChiBUSResult.OK;
        }

        public TapChiBUSResult SuaTrangThaiTapChi(clsTapChiDTO obj)
        {
            if (!this.TapChiDAO.UpdateStatus(obj))
                return TapChiBUSResult.DAOERROR;
            return TapChiBUSResult.OK;
        }

        public TapChiBUSResult XoaTapChi(clsTapChiDTO obj)
        {
            if (!this.TapChiDAO.Delete(obj))
                return TapChiBUSResult.DAOERROR;
            return TapChiBUSResult.OK;
        }
        #endregion
    }
}

